package cn.smbms.service.product;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.smbms.dao.product.ProductMapper;
import cn.smbms.pojo.Product;

@Service
public class ProductServiceImpl implements ProductService {
	@Resource
	private ProductMapper productMapper;

	// 获取轮播图
	@Override
	public List<Product> getImgs() {
		List<Product> pList = productMapper.getImgs();
		if (pList.size() == 0) {
			return null;
		}
		return pList;
	}

	// 按照typeid查询所有列表
	@Override
	public List<Product> getImgsByTypeId(Integer typeid) {
		List<Product> pList = productMapper.getImgsByTypeId(typeid);
		if (pList.size() == 0) {
			return null;
		}
		return pList;
	}

	// 张华鹏
	// 根据商品id查询

	@Override
	public Product getProductid(Integer id) {
		Product product = productMapper.getProductid(id);
		return product;
	}

	@Override
	public List<Product> getProucutType(Integer typeid, Integer proid) {
		List<Product> pList = productMapper.getProucutType(typeid, proid);
		return pList;
	}

	@Override
	public List<Product> getProductBySS(String nr) {
		List<Product> pList = productMapper.getProductBySS(nr);
		return pList;
	}

	// 查询最新
	@Override
	public List<Product> getNewProduct(String concatName, Integer one,
			Integer two) {
		List<Product> newList = productMapper.getNewProduct(concatName, one,
				two);
		return newList;
	}

	// 查询价格从高到低
	@Override
	public List<Product> getByHeight(String concatName, Integer one, Integer two) {
		List<Product> heightP = productMapper.getByHeight(concatName, one, two);
		return heightP;
	}

	// 查询价格从低到高
	@Override
	public List<Product> getByLow(String concatName, Integer one, Integer two) {
		List<Product> lowP = productMapper.getByLow(concatName, one, two);
		return lowP;
	}

	// 按照分类查询所有
	@Override
	public List<Product> getimgsById(Integer typeid) {
		List<Product> imgList = productMapper.getimgsById(typeid);
		return imgList;
	}

	// 价格0-99
	@Override
	public List<Product> getOne(String concatName) {
		List<Product> oneList = productMapper.getOne(concatName);
		return oneList;
	}

	// 价格100-499
	@Override
	public List<Product> getTwo(String concatName) {
		List<Product> twoList = productMapper.getTwo(concatName);
		return twoList;
	}

	// 价格>=500
	@Override
	public List<Product> getThree(String concatName) {
		List<Product> threeList = productMapper.getThree(concatName);
		return threeList;
	}

	@Override
	public int getCount(String concatName) {
		return productMapper.getCount(concatName);
	}

	@Override
	public List<Product> getProductByZh(String concatName, Integer one,
			Integer two) {
		return productMapper.getProductByZh(concatName, one, two);
	}
}
